package com.example.demo_mysql_mybatisplus.testTmp;

import cn.hutool.core.lang.TypeReference;
import cn.hutool.json.JSONObject;
import cn.hutool.json.JSONUtil;
import lombok.Data;

import java.util.*;

public class Test {
    public static void main(String[] args) {
        DDDD dddd = new DDDD();
        dddd.a = "d";
        dddd.b = 1;
        dddd.c=new Date();

        CCCC cccc = new CCCC();
        cccc.a = "c";
        cccc.b = 1;
        cccc.c=new Date();

        BBBB bbbb1 = new BBBB();
        bbbb1.a = "c1";
        bbbb1.b = 1;
        bbbb1.c=new Date();
        bbbb1.list = Arrays.asList(cccc);
        bbbb1.map = new HashMap(){{put(4444,dddd);}};

        Map<Long,Object> map = new HashMap<>();
        map.put(111L,bbbb1);

        String str = JSONUtil.toJsonStr(map);
        Map<Long,JSONObject> qwe = JSONUtil.toBean(str , new TypeReference<Map<Long,JSONObject>>() {} ,true);

        Map<Long,JSONObject> sdsf = JSONUtil.parse(str).toBean(new TypeReference<Map<Long,JSONObject>>() {} ) ;

        BBBB ccccc = JSONUtil.parse(qwe.get(111L)).toBean(new TypeReference<BBBB>() {} ) ;

        JSONObject jobj = JSONUtil.parseObj(map);
        BBBB cc = JSONUtil.parse(jobj.get("111")).toBean(new TypeReference<BBBB>() {} ) ;

        System.out.println();
    }

}

@Data
class AAAA{
    String a;
    Integer b;
    Date c;
    BBBB bbbb;
}
@Data
class BBBB{
    String a;
    Integer b;
    Date c;
    List<CCCC> list;
    Map<Long, DDDD> map;
}
@Data
class CCCC{
    String a;
    Integer b;
    Date c;
}
@Data
class DDDD{
    String a;
    Integer b;
    Date c;
}